/**
 * JAVACC DEMO 1.0
 */
package com.apache.match.queue;

/**
 * description:
 *
 * @author Administrator 创建时间：2017-1-9
 */
@SuppressWarnings("serial")
public class QueueAsc extends SupperQueue {

    public QueueAsc() {
        super();
    }

    public QueueAsc(long priceUnit, long timestamp, long orderNum, Object obj) {
        super(priceUnit, timestamp, orderNum, obj);
    }

    public int compareTo(Object o) {
        // 定义排序规则: Keyword对象里的属性i大的则排序时比较"大"(排序靠后)
        if (o instanceof QueueAsc) {
            if (this.priceUnit > ((QueueAsc) o).priceUnit) {
                return 1;
            } else if (this.priceUnit < ((QueueAsc) o).priceUnit) {
                return -1;
            } else if (this.priceUnit == ((QueueAsc) o).priceUnit) {
                if (this.timestamp > ((QueueAsc) o).timestamp) {
                    return 1;
                } else if (this.timestamp < ((QueueAsc) o).timestamp) {
                    return -1;
                } else {
                    if (this.orderNum < (((QueueAsc) o).orderNum)) {
                        return 1;
                    } else if (this.orderNum > (((QueueAsc) o).orderNum)) {
                        return -1;
                    }
                }
            }
            return 0;
        } else {
            // 非Keyword对象与之比较,则抛出异常
            throw new ClassCastException("Can't compare");
        }
    }
}
